﻿using System.Diagnostics.Contracts;
using System.Windows.Input;
using CoreMVVM.Commands;
using GIMS.Def.Arguments;
using System.Windows.Media;

namespace GIMS.GUI.ArgumentControls
{
    public class ColorArgumentControlViewModel
    {
        public ColorArgumentControlViewModel(ColorArgument colorArgument)
        {
            Contract.Requires(null != colorArgument);
            ColorArgument = colorArgument;
            ControlColor = Color.FromArgb(colorArgument.Color.A, colorArgument.Color.R, colorArgument.Color.G, colorArgument.Color.B);

            ApplyCommand = new DelegateCommand(Apply, CanApply);
        }

        public ICommand ApplyCommand { get; set; }

        private void Apply()
        {
            var drawingColor = System.Drawing.Color.FromArgb(ControlColor.A, ControlColor.R, ControlColor.G, ControlColor.B);
            ColorArgument.Color = drawingColor;
        }

        private bool CanApply() { return true; }

        public Color ControlColor { get; set; }

        private ColorArgument ColorArgument
        {
            get;
            set;
        }
    }
}
